#ifndef _____WARD_CHECKBOX_CPP
#define _____WARD_CHECKBOX_CPP


#include "driver.h"
#include "checkbox.h"



checkBox::checkBox(int x, int y, int w, int s)
 :uielement() 
{ 
	this->xpos = x; 
	this->ypos = y; 
	border = 2; 
	width = w; 
	data = 0; 

	if(s < 0) s = 0;
	
	style = s;
}

void checkBox::drawDisabled()
{
	glColor4f(0.0,0.0,0.0,1.0);
		glRectf(xpos-border,ypos-border,xpos+width+border,ypos+width+border);
	glColor4f(0.4,0.4,0.4,1.0);
		glRectf(xpos,ypos,32,32);
	if(data == 1)
	{
	glColor4f(0.0,0.0,0.0,1.0);
		glLineWidth(2.0);
		glBegin(GL_LINES);
			glVertex2f(xpos, ypos);
			glVertex2f(xpos+width,ypos+width);
			glVertex2f(xpos+width, ypos);
			glVertex2f(xpos,ypos+width);
		glEnd();
		glLineWidth(1.0);

	}

	glColor4f(0.0,0.3,0.0,0.5);

}


void checkBox::drawEnabled(int xpos, int ypos)
{
	glColor4f(cSec[0],cSec[1],cSec[2],1.0);
		glRectf(xpos-border, ypos-border, xpos+width+border, ypos+width+border);
	glColor4f(cPri[0],cPri[1],cPri[2],1.0);
		glRectf(xpos,ypos,xpos+width,ypos+width);

	if(data == 1)
	{
		drawStyle();

	}
	glColor4f(0.0,0.3,0.0,0.5);

}

void checkBox::drawStyle()
{
	if(style == CHECKBOX_CROSSLINES)
	{
	glColor4f(cTer[0],cTer[1],cTer[2],1.0);
		glLineWidth(3.0);
		glBegin(GL_LINES);
			glVertex2f(xpos, ypos);
			glVertex2f(xpos+width,ypos+width);
			glVertex2f(xpos+width, ypos);
			glVertex2f(xpos,ypos+width);
		glEnd();
		glLineWidth(1.0);
	}
	if(style == CHECKBOX_MINIBOX)
	{
	glColor4f(cTer[0], cTer[1], cTer[2], 1.0);
		glRectf(xpos+2,ypos+2,xpos+width-2,ypos+width-2);
	}
	if(style == CHECKBOX_CHECK)
	{
	glColor4f(cTer[0], cTer[1], cTer[2], 1.0);
		glLineWidth(3.0);
		glBegin(GL_LINES);
			glVertex2f(xpos,ypos+(width/2));
			glVertex2f(xpos+(width/2),ypos+(width));
			glVertex2f(xpos+(width/2),ypos+(width));
			glVertex2f(xpos+width,ypos);
		glEnd();
		glLineWidth(1.0);
	}



}








#endif